package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.come.model.Eshop;
import org.come.mouslisten.ShopingImgBorderMosulisten;
import org.come.mouslisten.ShopingOnlineBuyBtnForXianYuMouslisten;

/**
 * @author 黄建彬
 * @date : 2017年12月13日 下午4:41:29
 * 
 *       用来设置在线仙玉商城物品小面板
 */
public class GoodsMinXianYuJpanel extends JPanel {
	private JLabel buyBtn, buyCount, goodsImg;// 购买按钮,购买金额,物品图片

	public GoodsMinXianYuJpanel(Eshop eshop) {

		// 键盘监听
		this.setPreferredSize(new Dimension(80, 100));
		this.setLayout(null);
		// 设置控件信息
		buyBtn = new JLabel();
		buyBtn.setBounds(50, 80, 30, 20);
		buyBtn.setText("  买");
		buyBtn.setForeground(Color.yellow);// 设置字体颜色
		buyBtn.addMouseListener(new ShopingOnlineBuyBtnForXianYuMouslisten(eshop, buyBtn));
		// 设置购买金额
		buyCount = new JLabel();
		buyCount.setBounds(5, 78, 60, 20);
		buyCount.setText(eshop.getEshopprice());
		buyCount.setFont(new Font("宋体", Font.BOLD, 12));
		buyCount.setForeground(Color.yellow);// 设置字体颜色
		// 设置放置物品图片
		goodsImg = new JLabel();
		goodsImg.setBounds(10, 15, 60, 60);
		ImageIcon image = new ImageIcon("img/item/" + eshop.getEshopskin() + ".png");
		// image=new ImageIcon(image.getImage().getScaledInstance(60,
		// 60,Image.SCALE_DEFAULT));
		image.setImage(image.getImage().getScaledInstance(60, 60, Image.SCALE_DEFAULT));
		goodsImg.setIcon(image);
		goodsImg.addMouseListener(new ShopingImgBorderMosulisten(eshop));
		this.add(buyBtn);
		this.add(buyCount);
		this.add(goodsImg);
	}

	private ImageIcon icon;
	private ImageIcon icon2 = new ImageIcon("inkImg/hongmu/2/59_png.xy2uiimg.pop.png");
	private ImageIcon icon3 = new ImageIcon("inkImg/hongmu/2/22_png.xy2uiimg.ibg.png");
	private ImageIcon icon4 = new ImageIcon("inkImg/hongmu/2/btn_anniu0000(1).png");

	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		if (icon == null) {
            icon = new ImageIcon("inkImg/hongmu/2/106_png.xy2uiimg.sitem.png");
        }

		// 购物面板
		g.drawImage(icon.getImage(), 0, 0, 80, 100, this);
		// 设置显示金额
		g.drawImage(icon2.getImage(), 0, 78, 50, 20, this);
		// 设置物品图片
		g.drawImage(icon3.getImage(), 10, 15, 60, 60, this);
		// 设置购买按钮
		g.drawImage(icon4.getImage(), 50, 80, 30, 20, this);
	}

}
